{extend name="default/base/base_seller" /}

{block name="seller_main"}
<form method="get" action="">
    <table class="search-form">
        <tr>
            <th style="width: 90px;">&nbsp;关键词：</th>
            <!-- //<td>&nbsp;</td> -->

            <th> <select name="search_type">
                <option value="0" {if condition="$Request.param.search_type eq '0'"}selected="selected"{/if}>{$Think.lang.store_goods_index_goods_name}</option>
                <option value="2" {if condition="$Request.param.search_type eq '2'"}selected="selected"{/if}>{$Think.lang.platform_article_number}</option>
                <!-- <option value="3" {if condition="$Request.param.search_type eq '3'"}selected="selected"{/if}>供应商</option> -->
            </select>
            </th>
            <td class="w160"><input type="text" class="text w150" name="keyword" value="{$Request.param.keyword}"/></td>

            <th>分类：</th>
            <th>  <span dstype="gc1">
                {notempty name="gc_list"}
                <select dstype="gc" data-param="{deep:1}" name='gc_id'>
                    <option>{$Think.lang.ds_please_choose}</option>
                    {foreach name="gc_list" item="val"}
                    <option value="{$val.gc_id}">{$val.gc_name}</option>
                    {/foreach}
                </select>
                {/notempty}
            </span>
            </th>
            <th><span dstype="gc2"></span></th>
            <th><span dstype="gc3"></span></th>
            <th>品牌：</th>
            <th> <div class="dssc-brand-select">
                <div class="selection" style="text-align:left;">
                    <input name="b_name" id="b_name" value="{$Request.param.b_name|default=''}" type="text" class="text w180" readonly="readonly" />
                    <input type="hidden" name="b_id" id="b_id" value="{$goods.b_id|default=''}" />
                    <em class="add-on" dstype="add-on"><i class="iconfont">&#xe73a;</i></em></div>
                <div class="dssc-brand-select-container">
                    <div class="brand-index" data-tid="{$goods_class.type_id}" data-url="{:url('Sellergoodsadd/ajax_get_brand')}">
                        <div class="letter" dstype="letter">
                            <ul>
                                <li><a href="javascript:void(0);" data-letter="all">{$Think.lang.ds_all}</a></li>
                                <li><a href="javascript:void(0);" data-letter="A">A</a></li>
                                <li><a href="javascript:void(0);" data-letter="B">B</a></li>
                                <li><a href="javascript:void(0);" data-letter="C">C</a></li>
                                <li><a href="javascript:void(0);" data-letter="D">D</a></li>
                                <li><a href="javascript:void(0);" data-letter="E">E</a></li>
                                <li><a href="javascript:void(0);" data-letter="F">F</a></li>
                                <li><a href="javascript:void(0);" data-letter="G">G</a></li>
                                <li><a href="javascript:void(0);" data-letter="H">H</a></li>
                                <li><a href="javascript:void(0);" data-letter="I">I</a></li>
                                <li><a href="javascript:void(0);" data-letter="J">J</a></li>
                                <li><a href="javascript:void(0);" data-letter="K">K</a></li>
                                <li><a href="javascript:void(0);" data-letter="L">L</a></li>
                                <li><a href="javascript:void(0);" data-letter="M">M</a></li>
                                <li><a href="javascript:void(0);" data-letter="N">N</a></li>
                                <li><a href="javascript:void(0);" data-letter="O">O</a></li>
                                <li><a href="javascript:void(0);" data-letter="P">P</a></li>
                                <li><a href="javascript:void(0);" data-letter="Q">Q</a></li>
                                <li><a href="javascript:void(0);" data-letter="R">R</a></li>
                                <li><a href="javascript:void(0);" data-letter="S">S</a></li>
                                <li><a href="javascript:void(0);" data-letter="T">T</a></li>
                                <li><a href="javascript:void(0);" data-letter="U">U</a></li>
                                <li><a href="javascript:void(0);" data-letter="V">V</a></li>
                                <li><a href="javascript:void(0);" data-letter="W">W</a></li>
                                <li><a href="javascript:void(0);" data-letter="X">X</a></li>
                                <li><a href="javascript:void(0);" data-letter="Y">Y</a></li>
                                <li><a href="javascript:void(0);" data-letter="Z">Z</a></li>
                                <li><a href="javascript:void(0);" data-letter="0-9">{$Think.lang.ds_other}</a></li>
                                <li><a href="javascript:void(0);" data-empty="0">{$Think.lang.sellergoodsadd_empty}</a></li>
                            </ul>
                        </div>
                        <div class="search" dstype="search">
                            <input name="search_brand_keyword" id="search_brand_keyword" type="text" class="text" placeholder="{$Think.lang.brand_name_keyword_search}"/><a href="javascript:void(0);" class="dssc-btn-mini" style="vertical-align: top;">Go</a></div>
                    </div>
                    <div class="brand-list" dstype="brandList">
                        <ul dstype="brand_list">

                            {foreach name="brand_list" item="val"}
                            <li style="text-align: left;" data-id='{$val.brand_id}'data-name='{$val.brand_name}'><em>{$val.brand_initial}</em>{$val.brand_name}</li>
                            {/foreach}
                        </ul>
                    </div>
                    <div class="no-result" dstype="noBrandList" style="display: none;">{$Think.lang.does_not_match}"<strong>{$Think.lang.search_keywords}</strong>"{$Think.lang.conditional_brand}</div>
                </div>
            </div>
            </th>


            <td class="tc w70">
                <input type="submit" class="submit" value="{$Think.lang.ds_search}" />

            </td>
            <td><a href="{:url('sellergoodsinfomessage/perfect_goods_list')}" class="dssc-btn dssc-btn-acidblue ml5 mr5">
                <p>取消</p></td>
        </tr>
    </table>
</form>



<table class="dssc-default-table">
    <thead>
        <tr ds_type="table_header">
            <th class="w30"></th>
            <th class="w30">商品</th>
            <th class="w150"></th>
            <th class="w180">分类</th>
            <th class="w180">品牌</th>
            <th class="w100">审核状态</th>
            <th class="w100">上下架</th>
            <th class="w100">{$Think.lang.store_goods_index_add_time}</th>
            <th class="w150">{$Think.lang.ds_handle}</th>
        </tr>
       
    </thead>

    <tbody>
        {notempty name="goods_list"}
        {foreach name="goods_list" item="val" }
         <tr>
            <th colspan="20">&nbsp;&nbsp;平台货号:{$val.goods_commonid}</th>
        </tr>
        <tr>
            <td></td>
            <td><div class="pic-thumb"><img src="{:goods_thumb($val, 240)}"/></div></td>
            <td style="color: black;" class="tl">{$val.goods_name}</td>
            <td>{$val.gc_name}</td>
            <td>{$val.brand_name}</td>
            <td><span>停用</span></td>
            <td><span>下架</span></td>
            <td class="goods-time">{$val.goods_addtime|date="Y-m-d H:i:s",###}</td>
            <td class="dscs-table-handle">
                <span>
                     <a href="javascript:void(0);" onclick="goods_setting_info({$val['goods_commonid']});" class="btn-green">
                        <p >查看详情</p>
                    </a>
                </span> 
                <span><a href="{:url('Sellergoodsinfomessage/edit_goods',['commonid'=>$val.goods_commonid,'class_id'=>$val.gc_id_3])}" class="btn-blue"><p>编辑</p></a></span>
                <!-- <span><a href="javascript:void(0)" onclick="ds_ajaxget_confirm('{:url('Sellergoodsinfomessage/drop_goods',['commonid'=>$val.goods_commonid])}','{$Think.lang.ds_ensure_del}');" class="btn-red"><p>{$Think.lang.ds_del}</p></a></span> -->
                <span><a href="javascript:void(0)" onclick="ds_ajaxget_confirm('{:url('Sellergoodsinfomessage/drop_goods_lock',['commonid'=>$val.goods_commonid])}','{$Think.lang.ds_ensure_del}');" class="btn-red"><p>{$Think.lang.ds_del}</p></a></span>
            </td>
        </tr>
        <tr style="display:none;">
            <td colspan="7"><div class="dssc-goods-sku ps-container"></div></td>
        </tr>
        {/foreach}
        {else /}
        <tr>
            <td colspan="7" class="norecord"><div class="warning-option"><i class="iconfont">&#xe64c;</i><span>{$Think.lang.no_record}</span></div></td>
        </tr>
        {/notempty}
    </tbody>


    <tfoot>
        {notempty name="goods_list"}
        <tr>
            <td colspan="7"><div class="pagination"> {$show_page}</div></td>
        </tr>
        {/notempty}
    </tfoot>
</table>
<script src="{$Think.HOME_SITE_ROOT}/js/store_goods_list.js"></script> 

<script>
       $(function () {

      $('#import_mo').click(function(){
        var commonid = $(this).attr('commonid');
        //alert (commonid);return false;
        $.ajax({
                    url: "{:url('Sellergoodsonline/copy_good_template')}",
                    type: 'post',
                    data: {commonid:commonid},
                    success: function (e) {
                            layer.msg(e.data);
                          setTimeout(setTimeout(function(){
                                window.location.reload();
                            },2000));
                        }
                    
                });
      });  
     
     /* AJAX选择品牌 */
    // 根据首字母查询
    $('.letter[dstype="letter"]').find('a[data-letter]').click(function(){
        var _url = $(this).parents('.brand-index:first').attr('data-url');
        var _tid = $(this).parents('.brand-index:first').attr('data-tid');
        var _letter = $(this).attr('data-letter');
        var _search = $(this).html();
        $.getJSON(_url, {type : 'letter', tid : _tid, letter : _letter}, function(data){
            insertBrand(data, _search);
        });
    });
   $('.letter[dstype="letter"]').find('a[data-empty]').click(function(){
     $('#b_name').val("");
     });
  
  
    // 根据关键字查询
    $('.search[dstype="search"]').find('a').click(function(){
        var _url = $(this).parents('.brand-index:first').attr('data-url');
        var _tid = $(this).parents('.brand-index:first').attr('data-tid');
        var _keyword = $('#search_brand_keyword').val();
        $.getJSON(_url, {type : 'keyword', tid : _tid, keyword : _keyword}, function(data){
            insertBrand(data, _keyword);
        });
    });
    // 选择品牌
    $('ul[dstype="brand_list"]').on('click', 'li', function(){
        $('#b_id').val($(this).attr('data-id'));
        $('#b_name').val($(this).attr('data-name'));
        $('.dssc-brand-select > .dssc-brand-select-container').hide();
    });
    
    //搜索品牌列表滚条绑定
    $('div[dstype="brandList"]').perfectScrollbar();
    
    $('select[name="b_id"]').change(function(){
        getBrandName();
    });
    
    $('input[name="b_name"]').focus(function(){
        $('.dssc-brand-select > .dssc-brand-select-container').show();
    });
  //下拉隐藏显示品牌列表
        $('.add-on[dstype="add-on"]').click(function(){
            $('.dssc-brand-select > .dssc-brand-select-container').fadeToggle();
        });
   
   // 插入品牌
function insertBrand(param, search) {
    $('div[dstype="brandList"]').show();
    $('div[dstype="noBrandList"]').hide();
    var _ul = $('ul[dstype="brand_list"]');
    _ul.html('');
    if ($.isEmptyObject(param)) {
        $('div[dstype="brandList"]').hide();
        $('div[dstype="noBrandList"]').show().find('strong').html(search);
        return false;
    }
    $.each(param, function(i, n){
        $('<li  style="text-align: left;" data-id="' + n.brand_id + '" data-name="' + n.brand_name + '"><em>' + n.brand_initial + '</em>' + n.brand_name + '</li>').appendTo(_ul);
    });

    //搜索品牌列表滚条绑定
    $('div[dstype="brandList"]').perfectScrollbar('update');
}
});


       $(function () {
           // 查询下级分类，分类不存在显示当前分类绑定的规格
           $('select[dstype="gc"]').change(function() {
               $(this).parents('td:first').nextAll().html('');
               $('div[dstype="spec_ul"]').html('');
               $('div[dstype="spec_iframe"]').html('');
               getClassSpec($(this));
           });

           // ajax选择商品分类
           function getClassSpec($this) {
               var id = parseInt($this.val());
               var data_str = '';
               eval('data_str =' + $this.attr('data-param'));
               var deep = data_str.deep;
               if (isNaN(id)) {
                   // 清理分类
                   clearClassHtml(parseInt(deep) + 1);
               }
               $.getJSON('ajax_class?id=' + id + '&deep=' + deep, function(data) {
                   $('div[dstype="spec_iframe"]').empty();
                   $('div[dstype="spec_ul"]').empty();
                   // alert(data);
                   if (data) {
                       if (data.type == 'class') {
                           nextClass(data.data, data.deep,id);
                       } else if (data.type == 'spec') {
                           specList(data.data, data.deep, data.gcid);
                       }
                   }
               });
           }

           // 下一级商品分类
           function nextClass(data, deep,id) {

               $('span[dstype="gc' + deep + '"]').html('').append('<select data-param="{deep:' + deep + '}" name="gc_id"></select>')
                   .find('select').change(function() {
                   getClassSpec($(this));
               }).append('<option value="'+id+'" >{$Think.lang.ds_please_choose}</option>');
               $.each(data, function(i, n) {
                   if (n != null) {
                       $('span[dstype="gc' + deep + '"] > select').append('<option value="' + n.gc_id + '">' + n.gc_name + '</option>');
                   }
               });
               // 清理分类
               clearClassHtml(parseInt(deep) + 1);
           }

           // 清理二级分类信息
           function clearClassHtml(deep) {
               switch (deep) {
                   case 2:
                       $('span[dstype="gc2"]').empty();
                   case 3:
                       $('span[dstype="gc3"]').empty();
                       break;
               }
           }

       });



    //查看详情
    function goods_setting_info(ids_str) {
      _uri = HOMESITEURL+"/Sellergoodsadd/store_goods_detail?commonid=" + ids_str;
        dsLayerOpen(_uri,'查看详情','1200px','680px');
    }
    /**
 * Layer 通用ifram弹出窗口
 */
function dsLayerOpen(url, title,width,height) {
    if (!width) width = '900px';
    if (!height) height = '500px';
    layer.open({
        type: 2,
        title: title,
        area: [width,height],
        fixed: false, //不固定
        maxmin: true,
        content: url
    });
}   
</script>


{/block}
